package com.sky.haikangdemo.service;

import com.sky.haikangdemo.utils.HikVisionSDKInitUtil;
import com.sky.haikangdemo.config.PlateConfig;
import com.sky.haikangdemo.entity.PlateInfo;
import com.sky.haikangdemo.mapper.EnterMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service("exitService")
@Slf4j
public class ExitService {

    @Autowired
    private EnterMapper enterMapper;


    public void plateOut(PlateInfo plateInfo, String content) {
        String key = PlateConfig.deviceIp + PlateConfig.devicePort + PlateConfig.username + PlateConfig.password;
        log.info("车牌号:{}", plateInfo.getPlate() + "出场");
        enterMapper.deleteByPrimaryKey(plateInfo.getPlate());

        /**
         * 语音播报
         */
        HikVisionSDKInitUtil.voiceBroadcast(key, content + "," + plateInfo.getPlate()+"，一路顺风");


        /**
         * led播报
         */
        HikVisionSDKInitUtil.ledBroadcast(key, "一路顺风", plateInfo.getPlate());


        /**
         * 远程抬杆
         */
        HikVisionSDKInitUtil.remoteControl(key, PlateConfig.POLE_CLOSED);
    }
}
